/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author Francisco
 */
public class JPIntervencionesContenedor extends javax.swing.JPanel implements ActionListener {

    JPAltaIntervencion jpa;
    JPBajaIntervencion jpb;
    JPModificarIntervencion jpm;
    JPConsultarIntervencion jpc;

    public JPIntervencionesContenedor() {
        initComponents();

        jpa = new JPAltaIntervencion();
        jpb = new JPBajaIntervencion();
        jpm = new JPModificarIntervencion();
        jpc = new JPConsultarIntervencion();

        jpContenedor.setLayout(new CardLayout());

        jpContenedor.add(jpa, "jpAlta");
        jpContenedor.add(jpb, "jpBaja");
        jpContenedor.add(jpm, "jpModificar");
        jpContenedor.add(jpc, "jpConsultar");

        ((CardLayout) jpContenedor.getLayout()).show(jpContenedor, "jpAlta");

        btnAltaIntervencion.addActionListener(this);
        btnBajaIntervencion.addActionListener(this);
        btnModificarIntervencion.addActionListener(this);
        btnConsultarIntervencion.addActionListener(this);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        btnAltaIntervencion = new javax.swing.JButton();
        btnBajaIntervencion = new javax.swing.JButton();
        btnModificarIntervencion = new javax.swing.JButton();
        btnConsultarIntervencion = new javax.swing.JButton();
        jpContenedor = new javax.swing.JPanel();

        setPreferredSize(new java.awt.Dimension(800, 600));

        jToolBar1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        btnAltaIntervencion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/anadir.png"))); // NOI18N
        btnAltaIntervencion.setFocusable(false);
        btnAltaIntervencion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAltaIntervencion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnAltaIntervencion);

        btnBajaIntervencion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/borrar.png"))); // NOI18N
        btnBajaIntervencion.setFocusable(false);
        btnBajaIntervencion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnBajaIntervencion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnBajaIntervencion);

        btnModificarIntervencion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/modificar.png"))); // NOI18N
        btnModificarIntervencion.setFocusable(false);
        btnModificarIntervencion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnModificarIntervencion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnModificarIntervencion);

        btnConsultarIntervencion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/buscar.png"))); // NOI18N
        btnConsultarIntervencion.setFocusable(false);
        btnConsultarIntervencion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnConsultarIntervencion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnConsultarIntervencion);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)
            .addComponent(jpContenedor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpContenedor, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAltaIntervencion;
    private javax.swing.JButton btnBajaIntervencion;
    private javax.swing.JButton btnConsultarIntervencion;
    private javax.swing.JButton btnModificarIntervencion;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel jpContenedor;
    // End of variables declaration//GEN-END:variables

    @Override
    public void actionPerformed(ActionEvent e) {

        if (e.getSource() == btnAltaIntervencion) {

            ((CardLayout) jpContenedor.getLayout()).show(jpContenedor, "jpAlta");

        }

        if (e.getSource() == btnBajaIntervencion) {

            ((CardLayout) jpContenedor.getLayout()).show(jpContenedor, "jpBaja");

        }

        if (e.getSource() == btnModificarIntervencion) {

            ((CardLayout) jpContenedor.getLayout()).show(jpContenedor, "jpModificar");
        }

        if (e.getSource() == btnConsultarIntervencion) {

            ((CardLayout) jpContenedor.getLayout()).show(jpContenedor, "jpConsultar");
        }
    }
}
